/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gestores.acoes;

import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author blaster
 */
public class ActionFactory {

    //singleton
    private static ActionFactory instance;

    public static ActionFactory getInstance() {
        if (instance == null) {
            instance = new ActionFactory();
        }
        return instance;
    }
    HashMap<String, FWAction> acoes = new HashMap<String, FWAction>();

    private ActionFactory() {
        ArrayList<FWAction> fwacoes = new ArrayList<FWAction>();
        fwacoes.add(new AcaoNula());

        for (FWAction ac : fwacoes) {
            acoes.put(ac.getName(), ac);
        }

        fwacoes = null;
    }
    
    public <T extends FWAction> T getAction(String name) {
        FWAction ret = getInstance().acoes.get(name);
        if (ret == null) {
            ret = getInstance().acoes.get("Não Disponível");
        } 
        return (T)ret;
    }
}
